﻿using Microsoft.Xna.Framework.Graphics;

namespace Lab3.Entities
{
    class Jeep : Entity
    {
        private BasicEffect _effect;

        public Jeep(Camera camera, BasicEffect effect) : base(camera)
        {
            _effect = effect;
        }
        public override void Draw(int type)
        {
            if (type == GraphicsConstants.NormalDraw)
            {
                foreach (ModelMesh mesh in Model.Meshes)
                {
                    foreach (ModelMeshPart part in mesh.MeshParts)
                    {
                        _effect = (BasicEffect) part.Effect;
                        _effect = SceneBasicEffects(_effect);

                        if (((BasicEffect) part.Effect).TextureEnabled)
                        {
                            _effect.Texture = Texture;
                            _effect.TextureEnabled = true;
                        }
                        
                        _effect.View = Camera.View;
                        _effect.Projection = Camera.Projection;
                        _effect.World = ObjectWorld;

                        part.Effect = _effect;
                        part.Effect.Techniques[0].Passes[0].Apply();
                    }
                    mesh.Draw();
                }
            }
        }
    }
}
